package Agent;
import PacMan.*;
import dlife.ga.*;
import dlife.nn.FFNeuralNetwork;
import dlife.nn.SigmoidNeuron;

public class PacmanFitnessFunction implements IndividualFitnessFunction {
	
	public double evaluate(Individual indi) {
		//currently have 2 layers 8 nodes in the first layer 4 in the second
		int[] layers = new int[]{8,4};
		double[] weights = new double[SpeedTiming.NUM_GENES];
		for(int i = 0; i < weights.length; i++) {
			weights[i] = ((DoubleGene)indi.getGene(i)).getValue();
		}
		FFNeuralNetwork network = new FFNeuralNetwork(layers, weights, new SigmoidNeuron());
		
		//Game should do this
		//network.setInputs(game.getInputs());
		network.setInputs(new double[]{0,1,2,3,4,5,6,7});
		network.propagate();
		double[] outputs = network.getRawOutputs();
		
		double sum = 0;
		for(int i = 0; i < outputs.length; i++) {
			sum += outputs[i];
		}
		
		return sum;
		//return pacman.getTime();
	}
	
}
